% -----------
% Copyright 2013-2014, Andrew Lindesay
% Distributed under the terms of the MIT License.
% -----------

\section{Overview and General Information}

These documents relate to an ``application-server'' called ``Haiku Depot Server'' which vends an internet application that stores and allows interaction with software packages for the \href{http://www.haiku-os.org}{Haiku Operating System}.

The application server is able to communicate with remote repositories to retrieve ``Haiku Package Repository'' (.hpkr) files.  .hpkr files contain meta-data of the packages that are stored at that repository.  The application server is able to consume the .hpkr data and populate its own internal database with some of the meta-data that it contains.

The application-server then provides an HTTP-vended API as well as a web user-interface to the data.  The application server is also intended to interact with a desktop client also called ``Haiku Depot''.  The system augments the information acquired from the .hpkr data with additional detail such as;

\begin{itemize}
\item Screenshots
\item Icons
\item Comments
\end{itemize}

\subsection{License}

The license can be found in the file {\tt LICENSE.TXT} at the top level of the project source.  The license also applies to this documentation.

\subsection{Icon}

The icon for this project has been copied from the HaikuDepot application in the Haiku-OS source code repository and converted into SVG and PDF where appropriate.  Details of this are in the {\it haikudepotserver-webapp} project as a README.TXT file.

\subsection{Hosted Source Code}

The source code is hosted at;

\framebox{http://code.google.com/p/haiku-depot-web-app/}

\subsection{Prerequisites}
\label{prerequisites}

\begin{itemize}
\item \href{https://community.java.net/open-jdk}{Java} $\geqslant$ 1.7
\item \href{http://maven.apache.org}{Maven} $\geqslant$ 3.0.3
\item \href{http://www.postgres.org}{Postgres} database $\geqslant$ 9.1
\end{itemize}

On a debian host, these prerequisites can be installed with;

\begin{verbatim}
apt-get install default-jdk
apt-get install maven
apt-get install postgresql postgresql-client
\end{verbatim}

\subsubsection{Building on Linux}
\label{prerequisites-buildingonlinux}

The build system for a linux host requires the presence of RPM assembly tools.

\begin{tabular}{|l|l|}
\hline
RPM-based Linux & {\tt yum install rpm-build} \\
Debian-based Linux & {\tt apt-get install rpm} \\
\hline
\end{tabular}

\subsubsection{Basic Postgres Setup}

The setup discussed here is {\bf very simplistic} as it is not possible to envisage all of the possible environmental factors involved in a production deployment.  By this point, the Postgres database server is  installed on a UNIX-like computer system and is running as the system user {\tt postgres}.

To get the Postgres database server to listen on an internet socket, uncomment the {\tt postgresql.conf} file line;

\framebox{\tt listen\_address = `localhost'}

In order to get connections to localhost to take authentication via username and password, edit the table at the end of the {\tt pg\_hba.conf} file by modifying the ``METHOD'' column for rows pertaining to the localhost; change {\tt ident} to {\tt md5}.

The Postgres database server should then be restarted.

Create a new database user with the following command;

\framebox{\tt sudo -u postgres createuser -P -E haikudepotserver}

Now create the new database;

\framebox{\tt sudo -u postgres createdb -O haikudepotserver haikudepotserver}

You can check the login to the database works by opening a SQL terminal;

\framebox{\tt psql -h localhost -U haikudepotserver haikudepotserver}

The database schema objects will be automatically populated into the fresh database by the application-server as it launches.

\subsection{Basic ApacheDS LDAP Setup}

\fcolorbox{red}{white}{\parbox{\textwidth}{\color{red}The LDAP integration is not intended to be used at this point in time; these notes are here in case this aspect of the system is ever used.}}

LDAP can be used to store authentication details for the system.  In this section, it is assumed that the \href{http://directory.apache.org}{ApacheDS} is used and is configured through the Apache Studio tool, but it should be possible to use the system with another LDAP server.

\begin{enumerate}
\item Edit the ``example'' partition to be ``hikudepotserver'' and change the suffix to be ``dc=haiku-os,dc=org''.
\item Disallow anonymous access
\item Disable password policy
\item Start the server
\item Import the resource ``directory.ldif'' (found in the source)
\item Add new SSHA-256 ``userPassword'' attribute for the ``cn=haikudepotserver'' user in LDAP.
\item Configure the LDAP properties for the application and start
\item Synchronize the system's user data with LDAP using the action on the root operations page.
\end{enumerate}

